package com.nju.edu.erp.web.controller;

import com.nju.edu.erp.auth.Authorized;
import com.nju.edu.erp.enums.Role;
import com.nju.edu.erp.model.vo.promotion.PromotionVO;
import com.nju.edu.erp.service.promotion.PromotionService;
import com.nju.edu.erp.web.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping(path = "/promotion")
public class promotionController {
    private final PromotionService promotionService;

    @Autowired
    public promotionController(PromotionService promotionService) {
        this.promotionService=promotionService;
    }

    @PostMapping("/promotion")
    @Authorized(roles = {Role.ADMIN,Role.GM})
    public Response setStrategy(@RequestBody PromotionVO promotionVO) {
        System.out.println(promotionVO);
        System.out.println(promotionVO);
        System.out.println(promotionVO);

        promotionService.setStrategy(promotionVO);
        return Response.buildSuccess();
    }

    @GetMapping("/getPromotion")
    @Authorized(roles = {Role.ADMIN,Role.GM})
    public Response getPromotion() {
        return Response.buildSuccess(promotionService.getPromotion());
    }


}
